//
//  KInvoiceDAO.m
//  KutulusLaw
//
//  Created by Mahmood1 on 12/11/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "KInvoiceDAO.h"
#import "KResponedInvoiceCommandDTO.h"
@implementation KInvoiceDAO
- (BOOL)searchFile:(KBaseSearchCommandDTO *)searchCommandDTO block:(void (^)(KBaseResponedSearchCommandDTO *, NSError *))block {
	if ([self isValid:searchCommandDTO]) {
		
		MyApiClient *client = [MyApiClient sharedClient];
		NSMutableDictionary *parameters = [searchCommandDTO dictionary];
		NSLog(@"parameter of case api: %@", parameters);
		
		[client postPath:@"" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
			responseObject = [responseObject objectFromJSONData];
			NSLog(@"Response data from case api: %@", responseObject);
			
			KResponedInvoiceCommandDTO *responseCaseDTO = [[KResponedInvoiceCommandDTO alloc] initWithDictionary:responseObject ];
			
			block(responseCaseDTO, nil);
			
		} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
			block(nil, error);
		}];
		
		return YES;
	} 
	
	return NO;
}
@end
